package com.tony.pmp.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tony.pmp.model.entity.SysProductClassifyEntity;
import com.tony.pmp.model.mapper.SysProductClassifyMapper;
import com.tony.pmp.server.service.SysProductClassifyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: SysProductClassifyServiceImpl
 * @Auther: 皮蛋布丁
 * @Date: 2021/08/06/14:43
 * @Description: 商品类比
 */
@Service("sysProductClassifyService")
public class SysProductClassifyServiceImpl extends ServiceImpl<SysProductClassifyMapper,
        SysProductClassifyEntity> implements SysProductClassifyService {

    /**
    * @Description: queryAll 获取所有商品类别列表
    * @Param: []
    * @return: java.util.List<com.tony.pmp.model.entity.SysProductClassifyEntity>
    * @Author: 皮蛋布丁
    * @Date: 2021/8/7 10:40
    */
    @Override
    public List<SysProductClassifyEntity> queryAll() {
        return baseMapper.queryAll();
    }

    /**
    * @Description: getMaxCodeByParentId 根据父类id获取子类最大编码
    * @Param: [parentClassifyId]
    * @return: java.lang.String
    * @Author: 皮蛋布丁
    * @Date: 2021/8/8 11:02
    */
    @Override
    public String getMaxCodeByParentId(int parentClassifyId) {
        return baseMapper.getMaxCodeByParentId(parentClassifyId);
    }

    /**
    * @Description: getClassifyById 根据id获取商品分类数据
    * @Param: [id]
    * @return: com.tony.pmp.model.entity.SysProductClassifyEntity
    * @Author: 皮蛋布丁
    * @Date: 2021/8/8 19:48
    */
    @Override
    public SysProductClassifyEntity getClassifyById(int id) {
        return baseMapper.getClassifyById(id);
    }

    /**
    * @Description: delete 逻辑删除
    * @Param: [id]
    * @return: void
    * @Author: 皮蛋布丁
    * @Date: 2021/8/8 20:46
    */
    @Override
    public void delete(int id) {
        baseMapper.logicDelete(id);
    }

    /**
    * @Description: getClassifyByParentId 根据parentId获取子类分类数据
    * @Param: [id]
    * @return: boolean
    * @Author: 皮蛋布丁
    * @Date: 2021/8/8 20:59
    */
    @Override
    public boolean getClassifyByParentId(int id) {
        if (baseMapper.getClassifyByParentId(id) > 0) {
            return true;
        }
        return false;
    }
}
